package me.nujoug.net.dao;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.provider.BaseColumns;

public class HospitalDHBHelper extends SQLiteOpenHelper{
    // If you change the database schema, you must increment the database version.
    public static final int DATABASE_VERSION = 1;
    public static final String DATABASE_NAME = "HospitalEntry.db";

    public HospitalDHBHelper(Context context) {
        super(context, DATABASE_NAME, null, DATABASE_VERSION);
    }
    public void onCreate(SQLiteDatabase db) {
        db.execSQL(HospitalEntry.SQL_CREATE_ENTRIES);
    }
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        // This database is only a cache for online data, so its upgrade policy is
        // to simply to discard the data and start over
        db.execSQL(HospitalEntry.SQL_DELETE_ENTRIES);
        onCreate(db);
    }
    public void onDowngrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        onUpgrade(db, oldVersion, newVersion);
    }

    
    
    /* Inner class that defines the table contents */
    public static abstract class HospitalEntry implements BaseColumns {
        public static final String TABLE_NAME = "FoctApp_HospitalName";
        public static final String COLUMN_NAME_ENTRY_ID = "entryid";
        public static final String COLUMN_NAME_NAME = "name";
        public static final String COLUMN_NAME_DESC1 = "desc1";
        public static final String COLUMN_NAME_DESC2 = "desc2";
        public static final String COLUMN_NAME_NOTIFICATION = "notification";
        public static final String COLUMN_NAME_LEVEL = "Level";
        public static final String COLUMN_NAME_DISTRICT = "District";
        public static final String COLUMN_NAME_CATEGORY = "category";
        public static final String COLUMN_NAME_APPURL = "appUrl";
        
        private static final String TEXT_TYPE = " TEXT";
        private static final String COMMA_SEP = ",";
        private static final String SQL_CREATE_ENTRIES =
            "CREATE TABLE " + HospitalEntry.TABLE_NAME + " (" +
            		HospitalEntry._ID + " INTEGER PRIMARY KEY," +
            		HospitalEntry.COLUMN_NAME_ENTRY_ID + TEXT_TYPE + COMMA_SEP +
            		HospitalEntry.COLUMN_NAME_NAME + TEXT_TYPE + COMMA_SEP +
            		HospitalEntry.COLUMN_NAME_DESC1 + TEXT_TYPE + COMMA_SEP +
            		HospitalEntry.COLUMN_NAME_DESC2 + TEXT_TYPE + COMMA_SEP +
            		HospitalEntry.COLUMN_NAME_NOTIFICATION + TEXT_TYPE + COMMA_SEP +
            		HospitalEntry.COLUMN_NAME_LEVEL + TEXT_TYPE + COMMA_SEP +
            		HospitalEntry.COLUMN_NAME_DISTRICT + TEXT_TYPE + COMMA_SEP +
            		HospitalEntry.COLUMN_NAME_CATEGORY + TEXT_TYPE + COMMA_SEP +
            		HospitalEntry.COLUMN_NAME_APPURL + TEXT_TYPE + COMMA_SEP +
            " )";

        private static final String SQL_DELETE_ENTRIES =
            "DROP TABLE IF EXISTS " + HospitalEntry.TABLE_NAME;
    }
}
